local junshi = fk.CreateSkill {
  name = "lvshi__junshi",
}

Fk:loadTranslationTable{
  ["lvshi__junshi"] = "军势",
  [":lvshi__junshi"] = "你的回合内，当一名角色使用基本牌时，你可观看牌顶三张牌并弃置其中任意张牌，若弃置同名牌，此牌无效或基数+1。",
  ["#lvshi__junshi-card"] = "弃置其中任意张，若弃置【%arg】则令使用牌无效或基数+1",
  ["#lvshi__junshi-choice"] = "军势：选择令 %src 使用的 %arg 无效或基数+1？",
  ["lvshi__junshi_nullify"] = "无效",
  ["lvshi__junshi_plus"] = "基数+1",

  ["$lvshi__junshi1"] = "四世三公之家，当为天下之望。",
  ["$lvshi__junshi2"] = "大势在我，可怀问鼎之心。",
}

junshi:addEffect(fk.CardUsing, {
  anim_type = "offensive",
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(junshi.name) and data.card.type == Card.TypeBasic and player == player.room.current
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local top = room:getNCards(3)
    local param = {
      target = player,
      max = 3,
      min = 0,
      skill_name = junshi.name,
      flag = { card_data = { { "Top", top } } },
      prompt = "#lvshi__junshi-card:::"..data.card.trueName,
    }
    local cards = room:askToChooseCards(player, param)
    if #cards == 0 then return end
    room:moveCardTo(cards, Card.DiscardPile, nil, fk.ReasonPutIntoDiscardPile, junshi.name, nil, true, player)
    if table.find(cards, function (id)
      return Fk:getCardById(id).trueName == data.card.trueName
    end) then
      local choice = room:askToChoice(player, {
        choices = {"lvshi__junshi_nullify", "lvshi__junshi_plus"},
        skill_name = junshi.name,
        prompt = "#lvshi__junshi-choice:"..data.from.id.."::"..data.card:toLogString()
      })
      if choice == "lvshi__junshi_plus" then
        data.additionalDamage = (data.additionalDamage or 0) + 1
        data.additionalRecover = (data.additionalRecover or 0) + 1
        if data.card.trueName == "analeptic" and not (data.extra_data and data.extra_data.analepticRecover) then
          data.extra_data = data.extra_data or {}
          data.extra_data.additionalDrank = (data.extra_data.additionalDrank or 0) + 1
        end
        if data.card.name == "lvshi_poison" then
          data.extra_data = data.extra_data or {}
          data.extra_data.additionalPoison = (data.extra_data.additionalPoison or 0) + 1
        end
        if data.card.trueName == "scroll" then
          data.extra_data = data.extra_data or {}
          data.extra_data.additionalScroll = (data.extra_data.additionalScroll or 0) + 1
        end
      else
        data.toCard = nil
        data:removeAllTargets()
      end
    end
  end,
})


return junshi